home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / CLTIME.HPP < prev    next >
C/C++ Source or Header  |  1995-08-14  |  4KB  |  119 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    class.hpp
  5. //   Title:    C++ Class Libraries
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //    This module contains code for the class CL_TIME.
  24. //    This code.
  25. //
  26. //    The code in this module may be written in C++ or C.
  27. //
  28. //    This module is portable to:
  29. //        DOS 3.X+
  30. //        MS Windows 3.X+
  31. //        OS/2 2.X+
  32. //        OS/2 2.0 PM
  33. //
  34. //    The following compilers are supported:
  35. //        MSC 6.0A
  36. //        MSC/C++ 7.0
  37. //        Borland C++ 3.1 for DOS
  38. //        Borland C++ 1.0 for OS/2 2.X
  39. //
  40. //----------------------------------------------------------------------------
  41.  
  42. //----------------------------------------------------------------------------
  43. //    Constants and Local Variables.
  44. //----------------------------------------------------------------------------
  45. #define SECS_PER_DAY    (60L*60L*24L)
  46.  
  47.  
  48. //----------------------------------------------------------------------------
  49. //    Class CL_TIME
  50. //----------------------------------------------------------------------------
  51. #define CL_TIME_PARENT CL_OBJECT
  52. class CLASSTYPE CL_TIME : public CL_TIME_PARENT
  53. {
  54.     TIMET    ticks;                                // Number of seconds since Jan 1, 1970
  55.                                                     // < 0 is invalid
  56.     struct tm tm;                                // Converted time
  57.     BOOL fConverted;                            // TRUE if tm struct is valid
  58.  
  59. public:
  60.     FN_M CL_TIME(LONG = -1L);
  61.     FN_M CL_TIME(SHORT, SHORT, SHORT, SHORT = 0, SHORT = 0, SHORT = 0);
  62.     FN_M CL_TIME(RCCL_TIME);
  63.     virtual FN_M ~CL_TIME();
  64.  
  65.     BOOL FN_M AddDays(LONG);
  66.     BOOL FN_M AddSecs(LONG);
  67.     PSZ FN_M AMPM();
  68.     PSZ FN_M ampm();
  69.     SHORT FN_M Day();
  70.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  71.     BOOL FN_M Format(RCL_STRING, PCSZ = NULL);
  72.     LONG FN_M GetSec() const                // Seconds since Jan 1, 1970
  73.         {
  74.         return ticks;                            
  75.         }
  76.     SHORT FN_M Hour(BOOL= FALSE);
  77.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  78.     virtual BOOL FN_M IsValid() const;
  79.     SHORT FN_M JulianDay();
  80.     SHORT FN_M Minute();
  81.     SHORT FN_M Month();
  82.     PSZ FN_M MonthStr(BOOL = FALSE);
  83.     static TIMET FN_M Now(PTIMET  = NULL);
  84.     RCCL_TIME FN_M operator=(RCCL_TIME);
  85.     BOOL FN_M operator==(RCCL_TIME) const;
  86.     friend LONG FN_M operator-(RCCL_TIME, RCCL_TIME);
  87.     BOOL FN_M operator!=(RCCL_TIME) const;
  88.     FN_M operator LONG() const
  89.         {
  90.         return (LONG)ticks;
  91.         }
  92.     FN_M operator ULONG() const
  93.         {
  94.         return (ULONG)ticks;
  95.         }
  96.     virtual BOOL FN_M Retrieve(PCSZ, PCSZ = NULL);
  97.     SHORT FN_M Second();
  98.     BOOL FN_M Set(SHORT, SHORT, SHORT, SHORT = 0, SHORT = 0, SHORT = 0);
  99.     BOOL FN_M SetSec(LONG = -1);
  100.     virtual BOOL FN_M Store(PCSZ, PCSZ = NULL);
  101.     static BOOL FN_M Validate(SHORT, SHORT, SHORT, SHORT = 0, SHORT = 0, SHORT = 0);
  102.     SHORT FN_M Weekday();
  103.     PSZ FN_M WeekdayStr(BOOL = FALSE);
  104.     SHORT FN_M Year();
  105.  
  106.  
  107. #if COMPILE_DEBUG
  108.     static VOID FN_M Print(PCCL_TIME = NULL, PCSZ = NULL, SIZET = 0);
  109.     static BOOL FN_M Test(SHORT = 0);
  110. #endif
  111.  
  112. private:
  113.     BOOL FN_M Convert();
  114. };
  115. //----------------------------------------------------------------------------
  116. //------------------------------- End of File --------------------------------
  117. //----------------------------------------------------------------------------
  118.  
  119.